<?php
namespace control;
//管理员后台 - 抄送我的
class notifyMeClass extends adIndexClass
{
    private const page = 'notifyMe'; # 权限
    private const table = 'audit'; # 数据表
    private const title = '抄送我的';

    /*成本表列表-查询条件*/
    public function home()
    {
        $html =
            checkbox(['name' => 'see', 'title' => L('person.table.ckzt'), 'value' => ['是'=>'已查看', '否'=>'未查看'], 'checked' => ['否']]) .
            space .
            text(["name" => "orderNo", "title" => L('person.table.dan_ju_bian_hao')]) .
            text(["name" => "flowName", "title" => L('person.table.lcmc')]) .
            text(["name" => "applicantDepartment", "title" => L('person.table.sqbm')]) .
            text(["name" => "applicant", "title" => L('person.table.shen_qing_ren')]) .
            text(["name" => "commitTime", "title" => L('person.table.commitDate') . ' - ' . L('person.table.commitDate'), 'class' => 'text width200', 'laydate' => ['range' => '~', 'type' => 'date']]).
        select(["name" => "workFlow", "title" => L('person.table.dqjd'), 'option' => ['审核中', '已通过']]);
        //返回
        return $this->homeFun($this->search($html));
    }

    /*成本表列表-查询结果*/
    public function homeSearch()
    {
        if ($this->post('see')) {
            $where = " id in (SELECT typeId FROM `message` WHERE `stid` = '" . self::$stid . "' AND `see` IN (" . whereIn($this->post('see')) . ") ) ";
        } else {
            $where = " id in (SELECT typeId FROM `message` WHERE `stid` = '" . self::$stid . "' ) ";
        }
        $equal = [
            'workFlow' => $this->post('workFlow'),
        ];
        $like = [
            'orderNo' => $this->post('orderNo'),
            'flowName' => $this->post('flowName'),
            'applicantDepartment' => $this->post('applicantDepartment'),
            'applicant' => $this->post('applicant'),
        ];
        if ($this->post('commitTime')) {
            $where .= $this->timeComparison($this->post('commitTime'), field: 'commitTime');
        }
        $where .= search([
            "=" => $equal,
            "like" => $like,
        ]);
        $orderBy = ' commitTime DESC';
        //获取查询结果
        $page = $this->page([
            "table" => self::table,
            "where" => $where,
            "order" => $orderBy,

        ]);
        //获取表头
        $checkAll = $this->checkAll("listForm", "id");
        $tr[] = [$checkAll, L('person.table.dan_ju_bian_hao'), L('person.table.lcmc'), L('person.table.tjsj'), L('person.table.shen_qing_ren'), L('person.table.sqrbm'), L('person.table.dqjd'), L('person.table.dqspr'), L('person.table.sjdtjsj')];
        //获取记录
        foreach ($page['array'] as $array) {
            $url = root . "control/adIndex.html?cla=" . $array['targetCla'] . "&fun=" . $array['targetFun'];
            $dominate = [
                "box" => [
                    "name" => "id",
                    "value" => $array['id']
                ],
                "detail" => [
                    "title" => L('person.table.spxq'),
                    "click" => "newIframe('" . L('person.table.spxq') . "','" . $url . "&id=" . $array['targetId'] . "')"
                ],
            ];
            $tr[] = [$this->dominate($dominate), $array['orderNo'], $array['flowName'], $array['commitTime'], $array['applicant'], $array['applicantDepartment'], $array['workFlow'], $array['approver'], self::null($array['commitTimePrevious'])];
        }
        //控件
        $button = '';
        //返回
        $json['html'] = $page['hint'] . $button . "<form name='listForm'>" . space . $this->tableMany(array("tr" => $tr)) . "</form>" . $page['button'] . clear;
        return json_encode($json, 320);
    }
}
